//
//  SmartPoint.hpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/25.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef SmartPoint_hpp
#define SmartPoint_hpp

#include <stdio.h>
#include <iostream>

//智能指针实现原理
template <class T>
class AutoPtr1 {
private:
    T *m_ptr;
    
public:
    AutoPtr1(T *ptr=nullptr):m_ptr(ptr){
        
    }
    
    ~AutoPtr1(){
        delete m_ptr;
    }
    
    T &operator*(){
        return *m_ptr;
    }
    T *operator->(){
        return m_ptr;
    }
};

class Resource {
    
    
public:
    Resource(){
        std::cout << "resource init";
    }
    
    ~Resource(){
        std::cout << "resource dealloc";
    }
};


#endif /* SmartPoint_hpp */
